﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Asteroids
{
    class GameObject : DrawableGameComponent
    {
        public GameObject(Game g)
            : base(g)
        {

        }

        public Vector2 Position { get; set; }
        public Vector2 Velocity { get; set; }
        public Vector2 PausedVelocity { get; set; }
        public float Rotation { get; set; }
        public Rectangle boundingRectangle { get; set; }

        public void wrapAround(int screenWidth, int screenHeight, float spriteWidth, float spriteHeight)
        {
            //Wraps if X position goes off screen
            if (Position.X > screenWidth + spriteWidth)
                Position = new Vector2(Position.X - (screenWidth + 2 * spriteWidth), Position.Y);
            else if (Position.X < -spriteWidth)
                Position = new Vector2(Position.X + (screenWidth + 2 * spriteWidth), Position.Y);

            //Wraps if Y position goes off screen
            if (Position.Y > screenHeight + spriteHeight)
                Position = new Vector2(Position.X, Position.Y - (screenHeight + 2 * spriteHeight));
            else if (Position.Y < -spriteHeight)
                Position = new Vector2(Position.X, Position.Y + (screenHeight + 2 * spriteHeight));
        }

        public void collided()
        {
            //Eliminates boundingRectangle from game, if object is removed
            boundingRectangle = new Rectangle(-1000, -1000, 0, 0);
        }

        public void Paused()
        {
            PausedVelocity = Velocity;
            Velocity = new Vector2(0, 0);
        }

        public void UnPaused()
        {
            Velocity = PausedVelocity;
        }
    }
}
